package com.example.boot_6.map;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class Map_4 {
    public static void main(String[] args) {
        HashMap<Object, Object> map = new HashMap<>();
        map.put("k1", "v");
        map.put("k2", "v");
        map.put("k3", "v");
        map.put("k4", "v2");
        map.put("k5", "v3");
        map.put("k6", "v3");
        map.put(null,null);
        map.put(null,null);
        HashMap<Object,Object> map1 = new HashMap<>();
        List<Object> list = new ArrayList<>();
        map.entrySet().stream().forEachOrdered(e ->{
            if (!map1.containsKey(e.getValue())){
                map1.put(e.getValue(),e.getKey());
            }else {
                list.add(e.getValue());
            }
        });
        System.out.println(map1);
        System.out.println(list);
    }
}
